﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace WindowsGame1
{
    class Dialogue : BaseObject
    {
        public string m_szText;
        public Color m_cBGColor = Color.White;
        private float m_fEndString = 0.0f;

        public Dialogue()
        {
            m_ObjectType = OBJ_TYPE.OBJ_NONE;
            m_fDepth = 9999;
        }

        override public void Render(SpriteBatch spriteBatch, Camera cam)
        {
            Texture2D bg = GlobalContentManager.Instance.Texture("UI/TextBox");
            spriteBatch.Draw(bg, new Rectangle(0, 384, 1040, 256), m_cBGColor);

            SpriteFont fonti = GlobalContentManager.Instance.Font("Eichante");
            spriteBatch.DrawString(fonti, m_szText.Substring(0, (int)m_fEndString), new Vector2(8, 403), Color.Black);
        }

        override public void Update(float deltaT, KeyboardState LastKeyState)
        {
            if (m_fEndString < m_szText.Length)
                m_fEndString += deltaT;
            else
                m_fEndString = m_szText.Length;
            if (Keyboard.GetState().IsKeyUp(Keys.Enter) && LastKeyState.IsKeyDown(Keys.Enter))
            {
                if (m_fEndString >= m_szText.Length)
                    m_bIsAlive = false;
                else
                    m_fEndString = m_szText.Length;
            }
                
        }

        public override void CollisionResponse(BaseObject other)
        {
            
        }
    }
}
